package com.example.activitidemo.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Entity
@Data
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
@DynamicUpdate
public class Event implements Serializable {
    @Id
    @ApiModelProperty(value = "事件ID")
    @GenericGenerator(name = "UUID", strategy = "uuid")
    @GeneratedValue(generator = "UUID")
    private String id;
    private String content;
    @ApiModelProperty(value = "创建时间")
    @Temporal(TemporalType.TIMESTAMP)//时间类型格式化
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")//出参
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")//入参
    @Column(nullable = false, updatable = false)
    private Date date;
    @ApiModelProperty(value = "受理人ID")
    private String assignee;
    @ApiModelProperty(value = "天数", example = "1")
    private Integer day;
    @ApiModelProperty(value = "流程实例Id")
    private String processInstanceId;//流程实例Id
    @ApiModelProperty(value = "执行任务Id")
    private String taskId;
    @ApiModelProperty(value = "当前处理人ID")
    private String doingEmp;
    @ApiModelProperty(value = "完结时间")
    @Temporal(TemporalType.TIMESTAMP)//时间类型格式化
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")//出参
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")//入参
    private Date finishTime;
    @Transient
    @ApiModelProperty(value = "受理人姓名")
    private String assigneeName;
    @Transient
    @ApiModelProperty(value = "环节out的连线名称")
    private List<String> buttons;//环节out的连线名称
    @Transient
    @ApiModelProperty(value = "环节意见集合")
    private List<String> comments;
    @Transient
    @ApiModelProperty(value = "组ID")
    private String groupId;//组ID

    public Event() {
    }

    public Event(String id, String content, Date date, String assignee, Integer day, String processInstanceId, String assigneeName, List<String> buttons, List<String> comments, String groupId) {
        this.id = id;
        this.content = content;
        this.date = date;
        this.assignee = assignee;
        this.day = day;
        this.processInstanceId = processInstanceId;
        this.assigneeName = assigneeName;
        this.buttons = buttons;
        this.comments = comments;
        this.groupId = groupId;
    }

    public Event id(String val) {
        id = val;
        return this;
    }

    public Event content(String val) {
        content = val;
        return this;
    }

    public Event date(Date val) {
        date = val;
        return this;
    }

    public Event assignee(String val) {
        assignee = val;
        return this;
    }

    public Event day(Integer val) {
        day = val;
        return this;
    }

    public Event processInstanceId(String val) {
        processInstanceId = val;
        return this;
    }

    public Event assigneeName(String val) {
        assigneeName = val;
        return this;
    }

    public Event buttons(List<String> val) {
        buttons = val;
        return this;
    }

    public Event comments(List<String> val) {
        comments = val;
        return this;
    }

    public Event groupId(String val) {
        groupId = val;
        return this;
    }
}
